home *** CD-ROM | disk | FTP | other *** search
/ Gurewich OLE Controls for Visual Basic 4 / Gurewich OLE Controls for Visual Basic 4.iso / ocxprog / programs / ch03 / media.frm (.txt) next >
Encoding:
Visual Basic Form  |  1995-08-24  |  7.9 KB  |  251 lines

  1. VERSION 4.00
  2. Begin VB.Form frmMedia 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "The Media Program"
  5.    ClientHeight    =   1425
  6.    ClientLeft      =   1095
  7.    ClientTop       =   1830
  8.    ClientWidth     =   6585
  9.    Height          =   2115
  10.    Icon            =   "MEDIA.frx":0000
  11.    Left            =   1035
  12.    LinkTopic       =   "Form1"
  13.    MaxButton       =   0   'False
  14.    ScaleHeight     =   1425
  15.    ScaleWidth      =   6585
  16.    Top             =   1200
  17.    Width           =   6705
  18.    Begin MSComDlg.CommonDialog CommonDialog1 
  19.       Left            =   0
  20.       Top             =   0
  21.       _Version        =   65536
  22.       _ExtentX        =   847
  23.       _ExtentY        =   847
  24.       _StockProps     =   0
  25.       CancelError     =   -1  'True
  26.    End
  27.    Begin TegommLibCtl.Tegomm Tegomm1 
  28.       Height          =   1455
  29.       Left            =   0
  30.       TabIndex        =   0
  31.       Top             =   0
  32.       Width           =   6615
  33.       _version        =   65536
  34.       _extentx        =   11668
  35.       _extenty        =   2566
  36.       _stockprops     =   64
  37.       updateinterval  =   1000
  38.       bevelwidth      =   9
  39.    End
  40.    Begin VB.Menu mnuFile 
  41.       Caption         =   "&File"
  42.       Begin VB.Menu mnuOpenWav 
  43.          Caption         =   "Open &WAV File..."
  44.       End
  45.       Begin VB.Menu mnuOpenMidi 
  46.          Caption         =   "Open &MIDI File..."
  47.       End
  48.       Begin VB.Menu mnuOpenAvi 
  49.          Caption         =   "Open &AVI Video File..."
  50.       End
  51.       Begin VB.Menu mnuOpenCDAudio 
  52.          Caption         =   "Open &CD Audio"
  53.       End
  54.       Begin VB.Menu mnuSep1 
  55.          Caption         =   "-"
  56.       End
  57.       Begin VB.Menu mnuExit 
  58.          Caption         =   "E&xit"
  59.       End
  60.    End
  61.    Begin VB.Menu mnuHelp 
  62.       Caption         =   "&Help"
  63.       Begin VB.Menu mnuAbout 
  64.          Caption         =   "&About..."
  65.       End
  66.    End
  67. Attribute VB_Name = "frmMedia"
  68. Attribute VB_Creatable = False
  69. Attribute VB_Exposed = False
  70. ' All variables must be declared.
  71. Option Explicit
  72. Private Sub mnuAbout_Click()
  73.    Dim Title
  74.    Dim Msg
  75.    Dim CR
  76.    CR = Chr(13)
  77.    Title = "About the Media Program"
  78.    Msg = "This program was written with Visual "
  79.    Msg = Msg + "Basic for Windows, using the "
  80.    Msg = Msg + "TegoSoft Multimedia OCX control. "
  81.    Msg = Msg + CR + CR
  82.    Msg = Msg + "The TegoSoft Multimedia OCX control "
  83.    Msg = Msg + "is part of the TegoSoft OCX Control "
  84.    Msg = Msg + "Kit - a collection of various OCX controls. "
  85.    Msg = Msg + CR + CR
  86.    Msg = Msg + "For more information about the "
  87.    Msg = Msg + "TegoSoft OCX Control Kit, contact TegoSoft "
  88.    Msg = Msg + "at:"
  89.    Msg = Msg + CR + CR
  90.    Msg = Msg + "TegoSoft Inc." + CR
  91.    Msg = Msg + "P.O. Box 389" + CR
  92.    Msg = Msg + "Bellmore, NY 11710"
  93.    Msg = Msg + CR + CR
  94.    Msg = Msg + "Phone: (516)783-4824"
  95.    MsgBox Msg, vbInformation, Title
  96. End Sub
  97. Private Sub mnuExit_Click()
  98.     Unload Me
  99. End Sub
  100. Private Sub mnuOpenAvi_Click()
  101.    Dim Message
  102.    ' Set the File Type list box of the common
  103.    ' dialog.
  104.    CommonDialog1.Filter = _
  105.       "All Files (*.*)|*.*|Avi Video Files (*.avi)|*.avi"
  106.       
  107.    ' Set default File Type to WAV Files (*.wav).
  108.    CommonDialog1.FilterIndex = 2
  109.    ' Set an error trap.
  110.    On Error GoTo OpenAviError
  111.    ' Display the Open File dialog box.
  112.    CommonDialog1.Action = 1
  113.    ' Remove the error trap.
  114.    On Error GoTo 0
  115.    ' Open the selected WAV file.
  116.    Tegomm1.DeviceType = "AviVideo"
  117.    Tegomm1.filename = CommonDialog1.filename
  118.    Tegomm1.Command = "Open"
  119.    ' Check if file was opened successfully.
  120.    If Tegomm1.Error > 0 Then
  121.       Message = "Cannot open " + Tegomm1.filename
  122.       MsgBox Message, vbExclamation, "ERROR"
  123.       Me.Caption = "The Multimedia Program"
  124.       Exit Sub
  125.    End If
  126.    ' Set the caption of the form to the name
  127.    ' of the AVI file.
  128.    Me.Caption = "The Media Program - " + CommonDialog1.FileTitle
  129.       
  130.    ' Exit this procedure.
  131.    Exit Sub
  132. OpenAviError:
  133.    ' The user clicked the Cancel button of the
  134.    ' File Open dialog box.
  135.     Exit Sub
  136. End Sub
  137. Private Sub mnuOpenCDAudio_Click()
  138.    Dim Message
  139.    ' Open the CD Audio device.
  140.    Tegomm1.DeviceType = "CDAudio"
  141.    Tegomm1.Command = "Open"
  142.    ' Check if device was opened successfully.
  143.    If Tegomm1.Error > 0 Then
  144.       Message = "Cannot open the CD Audio device."
  145.       MsgBox Message, vbExclamation, "ERROR"
  146.       Me.Caption = "The Media Program"
  147.       Tegomm1.DeviceType = ""
  148.       Exit Sub
  149.    End If
  150.    ' Set the TimeFormat property of the multimedia control
  151.    ' to TMSF. From now on, the Position and Length properties
  152.    ' of the multimedia control will report values in units
  153.    ' of tracks.
  154.    Tegomm1.TimeFormat = "TMSF"
  155.    ' Update the program's window title.
  156.    Me.Caption = "The Media Program - Track " + Str(Tegomm1.Position)
  157. End Sub
  158. Private Sub mnuOpenMidi_Click()
  159.    Dim Message
  160.    ' Set the File Type list box of the common
  161.    ' dialog.
  162.    CommonDialog1.Filter = _
  163.       "All Files (*.*)|*.*|Midi Files (*.mid)|*.mid"
  164.       
  165.    ' Set default File Type to MID Files (*.mid).
  166.    CommonDialog1.FilterIndex = 2
  167.    ' Set an error trap.
  168.    On Error GoTo OpenMidiError
  169.    ' Display the Open File dialog box.
  170.    CommonDialog1.Action = 1
  171.    ' Remove the error trap.
  172.    On Error GoTo 0
  173.    ' Open the selected MIDI file.
  174.    Tegomm1.DeviceType = "Sequencer"
  175.    Tegomm1.filename = CommonDialog1.filename
  176.    Tegomm1.Command = "Open"
  177.    ' Check if file was opened successfully.
  178.    If Tegomm1.Error > 0 Then
  179.       Message = "Cannot open " + Tegomm1.filename
  180.       MsgBox Message, vbExclamation, "ERROR"
  181.       Me.Caption = "The Multimedia Program"
  182.       Exit Sub
  183.    End If
  184.    ' Set the caption of the form to the name
  185.    ' of the MIDI file.
  186.    Me.Caption = "The Media Program - " + CommonDialog1.FileTitle
  187.    ' Exit this procedure.
  188.    Exit Sub
  189. OpenMidiError:
  190.    ' The user clicked the Cancel button of the
  191.    ' File Open dialog box.
  192.     Exit Sub
  193. End Sub
  194. Private Sub mnuOpenWav_Click()
  195.    Dim Message
  196.    ' Set the File Type list box of the common
  197.    ' dialog.
  198.    CommonDialog1.Filter = _
  199.       "All Files (*.*)|*.*|Wav Files (*.wav)|*.wav"
  200.       
  201.    ' Set default File Type to WAV Files (*.wav).
  202.    CommonDialog1.FilterIndex = 2
  203.    ' Set an error trap.
  204.    On Error GoTo OpenWavError
  205.    ' Display the Open File dialog box.
  206.    CommonDialog1.Action = 1
  207.    ' Remove the error trap.
  208.    On Error GoTo 0
  209.    ' Open the selected WAV file.
  210.    Tegomm1.DeviceType = "WaveAudio"
  211.    Tegomm1.filename = CommonDialog1.filename
  212.    Tegomm1.Command = "Open"
  213.    ' Check if file was opened successfully.
  214.    If Tegomm1.Error > 0 Then
  215.       Message = "Cannot open " + Tegomm1.filename
  216.       MsgBox Message, vbExclamation, "ERROR"
  217.       Me.Caption = "The Multimedia Program"
  218.       Exit Sub
  219.    End If
  220.    ' Set the caption of the form to the name
  221.    ' of the WAV file.
  222.    Me.Caption = "The Media Program - " + CommonDialog1.FileTitle
  223.    ' Exit this procedure.
  224.    Exit Sub
  225. OpenWavError:
  226.    ' The user clicked the Cancel button of the
  227.    ' File Open dialog box.
  228.     Exit Sub
  229. End Sub
  230. Private Sub Tegomm1_Done()
  231.    ' If playback position reached end of file, rewind
  232.    ' the playback position.
  233.    If Tegomm1.Position = Tegomm1.Length Then
  234.       Tegomm1.Command = "Prev"
  235.    End If
  236. End Sub
  237. Private Sub Tegomm1_StatusUpdate()
  238.    Static OldPosition
  239.    ' If the device is not CD Audio, terminate
  240.    ' this procedure.
  241.    If Tegomm1.DeviceType <> "CDAUDIO" Then
  242.       Exit Sub
  243.    End If
  244.    ' If track has changed, update the program's
  245.    ' window caption.
  246.    If Tegomm1.Position <> OldPosition Then
  247.       Me.Caption = "The Media Program - Track " + Str(Tegomm1.Position)
  248.       OldPosition = Tegomm1.Position
  249.    End If
  250. End Sub
  251.